<template>
	<div>
		<TopNav/>
		<div class="commentpart">
			<!--把数据传递到子组件Comment中-->
			<Comment :info='commentInfo':index='index' :routeName='routename'/>		
		</div>
		<div class="discusspart">
			<GoodDiscuss :info='commentInfo':index='index' :routeName='routename'/>
		</div>
		<div class="alldiscuss">
			<Discuss :info='commentInfo':index='index' :routeName='routename'/>		   
		</div>
	</div>
</template>

<script>
	import TopNav from './topNav'
	import Comment from './comment'
	import Discuss from './alldiscuss'
	import GoodDiscuss from './gooddiscuss'
	export default{
		data(){
			return{
				commentInfo:[],
				index:null,
				routename:''
			}
		},
		components:{
			TopNav,
			Comment,
			Discuss,
			GoodDiscuss
		},
		created(){
			this.$axios.get('http://localhost:3000/commentList')
			.then(res => {
				this.commentInfo=res.data;	
				//通过传参的方式获取当前id,但是页面一刷新就拿不到数据了,所以利用本地缓存的方式
//				this.index=this.$route.params.id;
				this.index=localStorage.getItem('commentid');
				this.routename=this.$route.name;
			})
			.catch(error =>{
				console.log(error)
			})
//			
		}
	}
</script>

<style scoped lang="less">
	@current:100rem;
	.commentpart{
		margin-top: 88/@current;
	}
	.discusspart{
		height: 300/@current;
	}
	
</style>